Skip to content

Compression

Alt text

File Compression

  • The two most common forms of file compression are lossless file compression and lossy file compression.

  • Lossless compression: coding techniques that allow subsequent decoding to recreate exactly the original file.

  • Lossy compression: coding techniques that cause some information to be lost so that the exact original file cannot be recovered in subsequent decoding.

Alt text

Compression

The two most common forms of file compression are file compression and file compression.

[0/1]

Compression

compression techniques cannot recover the original file when decompressing?

[0/1]

Text Compression

  • Run-length encoding (RLE) can be used to compress a number of different file formats, especially for the text file.

  • It is a form of lossless file compression that reduces the size of a string of adjacent, identical data.

  • Consider the text string ‘aaaaabbbbccddddd’.

  • Assuming each character requires 1byte, then this string needs 16 bytes.

  • If we assume ASCII code is being used, then the string can be coded as follows, which only needs 8 bytes:

Alt text

Text Compression

Run-length encoding (RLE) is a form of file compression that reduces the size of a string of adjacent, identical data.

[0/1]

Audio Compression

  • MPEG-3 (MP3) uses technology known as audio compression to convert music and other sounds into an MP3 file format which use lossy compression.

  • Perceptual music shaping removes certain sounds:

    • frequencies that are outside the human hearing range
    • if two sounds are played at the same time, only the louder one can be heard by the ear, so the softer sound is eliminated.

Audio Compression

Perceptual music shaping removes certain sounds:

[0/1]

Video Compression

  • MPEG-4 (MP4) files are slightly different to MP3 files.
  • This format allows the storage of multimedia files rather than just sound. Music, videos, photos and animation can all be stored in the MP4 format.

Image Compression

  • When a photographic file is compressed, both the file size and quality of image are reduced.

  • A common file format for images is JPEG, which uses lossy file compression.

  • Vector graphics can also undergo some form of file compression.

  • Scalable vector graphics (.svg) are defined in XML text files which, therefore, allows them to be compressed, which uses lossless file compression.

Alt text

Image compression

A common file format for images is JPEG, which uses file compression. Vector graphics uses file compression.

[0/1]

(Using RLE with images)

  • For a black and white image, a white square has a value 1 and a black square a value of 0.

Alt text

  • The 8 × 8 grid would need 64 bytes; the compressed RLE format has 30 values, and therefore needs only 30 bytes to store the image.

General methods of compressing files

Alt text

Activity

  • Give an example of a lossless file format and an example of a lossy file format.
  • What is meant by lossless and lossy file compression?
  • Explain why it is often necessary to compress stored music files.
  • Describe how RLE compresses a file. Give an example in your description.
  • What is meant by run length encoding?
  • Describe how music picked up by a microphone is turned into a digitised music file in a computer.
  • Describe how the music quality is essentially retained.